package com.care.wardmate.remote.factory;

import com.care.common.core.domain.Result;
import com.care.wardmate.common.domain.Review;
import com.care.wardmate.remote.ReviewRemoteService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import org.slf4j.Logger;

import java.util.List;

@Component
public class ReviewRemoteServiceFallbackFactory implements FallbackFactory<ReviewRemoteService> {
    public final static Logger logger = org.slf4j.LoggerFactory.getLogger(ReviewRemoteServiceFallbackFactory.class);
    @Override
    public ReviewRemoteService create(Throwable cause) {
        logger.error("远程调用失败,原因:{}",cause.getMessage());
        return new ReviewRemoteService() {
            @Override
            public Result<List<Review>> selectReviewById(Integer articleId) {
                return Result.error("评论列表调用失败,请联系管理员");
            }
        };
    }
}
